﻿using System;

namespace Ops.Mpc.ValidationServices.Attributes
{
    [AttributeUsage(AttributeTargets.Property)]
    public class RequiredBooleanAttribute : ValidationAttribute
    {
        public RequiredBooleanAttribute()
        {
            this.Requires = true;
        }

        public override bool Validate(object container, object data, string[] propertyNames)
        {
            bool? boolean = data as bool?;

            return boolean.HasValue && boolean == Requires;
        }

        public bool Requires
        {
            get;
            set;
        }
    }
}
